import React from 'react'
import { BrowserRouter as Router, Route, Link, NavLink, Redirect, Switch, withRouter } from 'react-router-dom'
import Css from '../../style/common.module.css'
import Play from '../../img/视频播放a.png'

import MoreShipin from "./detaill"
class Danqu extends React.Component {
  constructor(){
    super()
    this.state={
      arr:[]
    }
  }
componentWillMount(){
    let {name}=this.props
    fetch(`http://106.12.79.128:666/search?keywords=${name}&type=1014`)
    .then(body=>body.json())
    .then(res=>{
        // console.log(res.result.artists)
        this.setState({
          arr:res.result.videos
        })
    })
}
dianji(){
  console.log(this.props.history)
  // this.props.history.push("/morevideo")
}
Appendzero (obj) {
    if (obj < 10) return "0" + obj; else return obj;
}
render() {
  
  return (
      <div>
          {this.state.arr.map((item,index)=>{
          return( 
            <Link to={`/morevideo?${item.vid}`} key={index}>
              <div onClick={this.dianji.bind(this)}> 
                  <div className={Css.videoList}>
                      <div className={Css.playCount}>
                          <img src={Play} alt=""className={Css.playvv} />
                          <p className={Css.playCountP}>{(item.durationms/10000).toFixed(1)}万</p>
                      </div>
                      <img src={item.coverUrl} alt="" className={Css.videosImg}/>
                      <div className={Css.videosP}>
                          <p  className={Css.videosP1}>{item.title}</p>
                          <p className={Css.videosP2}>{`${this.Appendzero(parseInt(item.playTime/1000/60%60))}:${this.Appendzero(parseInt(item.playTime/1000%60))} by ${item.creator[0].userName}`}</p>
                      </div>
                  </div>
                 
              </div>
              </Link>
          )
          })
          }
      </div>
  );
}
}

export default Danqu